package View;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Font;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;

import net.miginfocom.swing.MigLayout;
import java.awt.event.ActionListener;

public class SignInPage extends JPanel{
	
	private JPanel logInPanel;
	private JPanel infoPanel;
	private JPanel titleBarPanel;
	private JLabel userNameLabel;
	private JTextField userNameTextField;
	private JLabel passwordLabel;
	private JPasswordField passwordTextField;
	private JButton signInButton;
	
	public SignInPage(){
		setLayout(new  MigLayout());
		
		initComponent();
		addComponent();
	}
	
	private void initComponent(){
		
		logInPanel = new JPanel();
		logInPanel.setLayout(new MigLayout());
		logInPanel.setBackground(Color.LIGHT_GRAY);
		
		infoPanel = new JPanel();
		infoPanel.setLayout(new MigLayout());
		infoPanel.setBackground(Color.LIGHT_GRAY);
		
		titleBarPanel = new JPanel();
		titleBarPanel.setBackground(Color.black);
		
		userNameLabel = new JLabel("Username:");
		userNameLabel.setFont(new Font("Arial", Font.PLAIN, 15));
		userNameTextField = new JTextField(30);
		passwordLabel = new JLabel("Password:");
		passwordLabel.setFont(new Font("Arial", Font.PLAIN, 15));
		passwordTextField = new JPasswordField(30);
		signInButton = new JButton("Log In");
		
	}
	
	private void addComponent(){
		addToInfo();
		logInPanel.add(infoPanel, "wrap");
		logInPanel.add(signInButton, "gapleft 315");
		add(logInPanel, "h 150, w 500");
		add(titleBarPanel, BorderLayout.NORTH);
	}
	
	private void addToInfo(){
		infoPanel.add(userNameLabel, "gapleft 60");
		infoPanel.add(userNameTextField, "wrap 20");
		infoPanel.add(passwordLabel, "gapleft 60");
		infoPanel.add(passwordTextField);
	}
	
	public void signInListener(ActionListener listener){
		signInButton.addActionListener(listener);
	}
}
